package fr.isima.myextant;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import fr.isima.myant.Task;

public class DeleteTask extends Task{
	private String file;
	
	public DeleteTask() {}

	public DeleteTask(String file) {
		super();
		this.file = file;
	}
	
	public DeleteTask(String file, String parent) {
		super();
		this.file = file;
	}
	
	public void setFile(String file) {
		this.file = file;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		
		sb.append("\t\tName : DeleteTask");
		sb.append("\t\tfile " + file);
		sb.append("\n");
		
		return sb.toString();
	}
	
	@Override
	public void execute() {
		Path filePath = Paths.get(file);
		try {
			Files.delete(filePath);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}